import 'package:fig/views/widget/button/circle_button.dart';
import 'package:flutter/material.dart';
import 'package:video_player/video_player.dart';

class VideoControlCover extends StatefulWidget {
  final VideoPlayerController controller;
  final GestureTapCallback replayTapCallback;
  final GestureTapCallback playTapCallback;
  final GestureTapCallback forwardTapCallback;
  final Function onHidden;

  const VideoControlCover(this.controller, {Key key, this.replayTapCallback, this.playTapCallback, this.forwardTapCallback, this.onHidden}) : super(key: key);

  @override
  State<StatefulWidget> createState() => _ControlCoverState();
}

class _ControlCoverState extends State<VideoControlCover> {
  void backgroundTap() {
    print('backgroundTap');
    widget.onHidden();
  }

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      child: Container(
        color: Colors.black26,
        child: Center(
            child: Row(
          mainAxisSize: MainAxisSize.min,
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            CircleButton(icon: Icons.replay_10, onTap: widget.replayTapCallback),
            CircleButton(icon: widget.controller.value.isPlaying ? Icons.pause : Icons.play_arrow, onTap: widget.playTapCallback, iconSize: 60.0, margin: EdgeInsets.only(left: 40, right: 40)),
            CircleButton(icon: Icons.forward_10, onTap: widget.forwardTapCallback),
          ],
        )),
      ),
      onTap: backgroundTap,
    );
  }
}
